package com.itdaan.portal.business.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.itdaan.portal.business.domain.Permission;
import com.itdaan.portal.business.mapper.PermissionMapper;
import com.itdaan.portal.business.service.PermissionService;
import com.itdaan.portal.common.exception.ServiceException;
/**
 * @author www.itdaan.com
 */
@Service(value = "permissionService")
public class PermissionServiceImpl implements PermissionService{
	@Autowired
	private PermissionMapper permissionMapper;

	public void insert(Permission permission) throws ServiceException{
		permissionMapper.insert(permission);
	}

	public void deleteByIds(String ids)  throws ServiceException{
		for (String id : ids.split(",")) {
			permissionMapper.deleteById(Integer.parseInt(id));
		}
	}
	
	public void update(Permission permission) throws ServiceException{
		permissionMapper.update(permission);
	}

	public Permission getById(int id)  throws ServiceException{
		return permissionMapper.getById(id);
	}

	public List<Permission> getAll()  throws ServiceException{
		return permissionMapper.getAll();
	}

	public List<Permission> getByUserId(int userId)  throws ServiceException{
		return permissionMapper.getByUserId(userId);
	}

}
